// 校验手机号码
export const validatePhone = (rule, value, callback) => {
  const phonereg = /^[1][3,4,5,7,8][0-9]{9}$/;
  if (!value) return callback(new Error("手机号不能为空"));
  if (!phonereg.test(value)) {
    callback(new Error("请输入正确手机号"));
  } else {
    callback();
  }
};

// 校验邮箱
export const validateEmail = (rule, value, callback) => {
  const eMailreg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
  if (!value) return callback(new Error("邮箱不能为空"));
  if (!eMailreg.test(value)) {
    callback(new Error("请输入正确邮箱"));
  } else {
    callback();
  }
};

// 座机电话
export const validateCellPhone = (rule, value, callback) => {
  const phonereg = /^0\d{2,3}-?\d{7,8}$/;
  if (!value) return callback(new Error("公司电话不能为空"));
  if (!phonereg.test(value)) {
    callback(new Error("请输入正确电话号码"));
  } else {
    callback();
  }
};
